<?php
	require_once('include/menu.class.php');
	require_once('include/user.class.php');
	require_once('include/database.class.php');
	$menu = Menu::create();
	$db = new Database();
	User::start();
	echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="pl">
<head>
	<title>Baza danych obiektów turystycznych</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="icon" type="image/png" href="images/photos.png">
	<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
	<?php
		echo $menu;
	?>
	<?php
		if(false)
		{
			?>
				<div id="success-listing">
				<ul>
			<?php

			?>
				</ul>
				</div>
			<?php
		}
		if(!User::isAdmin())
		{
			?>
				<div id="error-listing">
				<ul>
			<?php
				if(!User::isAdmin()) echo '<li>Nie jesteś administratorem!</li>';

			?>
				</ul>
				</div>
			<?php
		}
		if(User::isAdmin())
		{
			$categories = $db->query('SELECT id_kat, nazwa FROM kategorie;');
	?>
	<div id="admin-container" >
		<h3><img src="images/photo_add.png" /> Dodaj obiekt</h3>
		<form method="post" action="addobject.php" >
			<table class="object-add-form">
			<tr><td class="desc">Kategoria:</td>
			<td class="f_text">
				<select name="id_kat">
					<?php
						foreach($categories as $category)
						{
							echo '<option value="'.$category['id_kat'].'">'.$category['nazwa'].'</option>';
						}
					?>
				</select>
			</td>
			</tr>
			<tr><td class="desc">Nazwa obiektu:</td><td class="f_text"><input type="text" name="nazwa" /></td></tr>
			<tr><td class="desc">Pojemność:</td><td class="f_text"><input type="text" name="pojemnosc" /></td></tr>
			<tr><td class="desc">Kraj:</td><td class="f_text"><input type="text" name="kraj" /></td></tr>
			<tr><td class="desc">Miasto:</td><td class="f_text"><input type="text" name="miasto" /></td></tr>
			<tr><td class="desc">Województwo:</td><td class="f_text"><input type="text" name="wojewodztwo" /></td></tr>
			<tr><td class="desc">Adres:</td><td class="f_text"><input type="text" name="adres" /></td></tr>
			<tr><td colspan="2"><span class="desc">Krótki opis:</span></td></tr>
			<tr><td colspan="2" class="f_textarea"><textarea name="opis_kr" ></textarea></td></tr>
			<tr><td colspan="2"><span class="desc">Długi opis:</span></td></tr>
			<tr><td colspan="2" class="f_textarea"><textarea name="opis_dl" ></textarea></td></tr>
			<tr><td colspan="2"><input type="submit" name="submit" value="Dodaj obiekt" /></td></tr>
			</table>
		</form>
	</div>
	<?php
		}
	?>
</body>
</html>